package com.smart.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.smart.common.annotation.Log;
import com.smart.common.core.controller.BaseController;
import com.smart.common.core.domain.AjaxResult;
import com.smart.common.enums.BusinessType;
import com.smart.manage.domain.DoctorConsultation;
import com.smart.manage.service.IDoctorConsultationService;
import com.smart.common.utils.poi.ExcelUtil;
import com.smart.common.core.page.TableDataInfo;

/**
 * 就诊管理Controller
 * 
 * @author lingyao
 * @date 2025-02-19
 */
@RestController
@RequestMapping("/manage/doctorConsultation")
public class DoctorConsultationController extends BaseController
{
    @Autowired
    private IDoctorConsultationService doctorConsultationService;

    /**
     * 查询就诊管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:doctorConsultation:list')")
    @GetMapping("/list")
    public TableDataInfo list(DoctorConsultation doctorConsultation)
    {
        startPage();
        List<DoctorConsultation> list = doctorConsultationService.selectDoctorConsultationList(doctorConsultation);
        return getDataTable(list);
    }

    /**
     * 导出就诊管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:doctorConsultation:export')")
    @Log(title = "就诊管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DoctorConsultation doctorConsultation)
    {
        List<DoctorConsultation> list = doctorConsultationService.selectDoctorConsultationList(doctorConsultation);
        ExcelUtil<DoctorConsultation> util = new ExcelUtil<DoctorConsultation>(DoctorConsultation.class);
        util.exportExcel(response, list, "就诊管理数据");
    }

    /**
     * 获取就诊管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:doctorConsultation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(doctorConsultationService.selectDoctorConsultationById(id));
    }

    /**
     * 新增就诊管理
     */
    @PreAuthorize("@ss.hasPermi('manage:doctorConsultation:add')")
    @Log(title = "就诊管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DoctorConsultation doctorConsultation)
    {
        return toAjax(doctorConsultationService.insertDoctorConsultation(doctorConsultation));
    }

    /**
     * 修改就诊管理
     */
    @PreAuthorize("@ss.hasPermi('manage:doctorConsultation:edit')")
    @Log(title = "就诊管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DoctorConsultation doctorConsultation)
    {
        Long doctorId = getUserId();
        doctorConsultation.setDoctorId(doctorId);
        return toAjax(doctorConsultationService.updateDoctorConsultation(doctorConsultation));
    }

    /**
     * 删除就诊管理
     */
    @PreAuthorize("@ss.hasPermi('manage:doctorConsultation:remove')")
    @Log(title = "就诊管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(doctorConsultationService.deleteDoctorConsultationByIds(ids));
    }
}
